<template>
  <view>
    <uni-popup ref="latShow" type="center"
               :maskClick="false"
               border-radius="10px 10px 0 0">
      <view class="pop-box">
        <view class="title">编辑地址</view>
        <view class="content">
          <view class="item">
            <view class="l">收货人：</view>
            <view class="r">
              <input v-model="addressForm.real_name" placeholder="请输入"/>
            </view>
          </view>
          <view class="item">
            <view class="l">联系电话：</view>
            <view class="r">
              <input v-model="addressForm.user_phone" placeholder="请输入"/>
            </view>
          </view>
          <view class="item" style="align-items: flex-start">
            <view class="l">收货地址：</view>
            <view class="r">
              <textarea v-model="addressForm.user_address" maxlength="999" placeholder="请输入"
                        style="width: 100%;height: 100px;font-size: 28rpx;border-bottom: 1rpx solid #ddd;"/>
            </view>
          </view>
        </view>
        <view class="footer">
          <view class="btn cancel" @click="close">取消</view>
          <view class="btn confirm" @click="save">确定</view>
        </view>
      </view>
    </uni-popup>
  </view>
</template>

<script>
import UniPopup from "../../../uni_modules/uni-popup/components/uni-popup/uni-popup.vue";
import {editAddress} from "@/api/admin"
export default {
  components: {UniPopup},
  props:['nowItem'],
  data() {
    return {
      addressForm:{}
    }
  },
  mounted(){
    this.$refs.latShow.open()
    this.addressForm={
      real_name:this.nowItem.real_name,
      user_phone:this.nowItem.user_phone,
      user_address:this.nowItem.user_address,
    }
  },
  methods: {
    open(){

    },
    close(){
      this.$emit('close','addressShow')
    },
    save(){
      editAddress(this.nowItem.id,this.addressForm).then(res=>{
        if(res.status===200){
          // 提示成功
          this.$util.Tips({ title: '编辑成功'})
          this.$emit('refresh')
          this.close()
        }
      })
    }
  },
}
</script>

<style lang="scss" scoped>
.pop-box{
  width: 90vw;
  max-height: 66vh;
  padding: 30rpx;
  border-radius: 28rpx;
  background: #fff;
  .title{
    font-size: 30rpx;
    margin-bottom: 30rpx;
    font-weight: bold;
  }
  .content{
    .item{
      display: flex;
      align-items: center;
      margin-bottom: 30rpx;
      .l{
        white-space: nowrap;
        flex: 0 0 150rpx;
      }
      .r{
        flex:1;
        padding-right: 30rpx;
      }
    }
  }
  .footer{
    display: flex;
    justify-content: center;
    margin-top: 30rpx;
    .btn{
      padding: 0 50rpx;
      line-height: 60rpx;
      border-radius: 28rpx;
    }
    .cancel{
      color: #333;
      border: 1rpx solid #CCCCCC;
      margin-right: 30rpx;
    }
    .confirm{
      color: #fff;
      background: #1497fa;
    }
  }
}
input{
  font-size: 28rpx;
  border-bottom: 1rpx solid #ddd;
  width: 100%;
}
</style>